/**
 * Created by Administrator on 2015/1/18.
 */
var articleInfoApp = angular.module('articleInfoApp', []);

/** 读取文章控制器 */
articleInfoApp.controller('articleCtrl', [ '$scope', '$http', articleCtrl ]);
function articleCtrl($scope, $http) {
	var par = {
		wx : GetQueryString('wxid'),
		articleid : GetQueryString('articleid')
	};
	$scope.article = "文章加载中....";
	console.log(par);
	$scope.imgsrc = "";
	$scope.title="";
    $scope.menu = "";
	$scope.load = function() {
		$http({
			method : 'post',
			url : '../articleInfo',
			params : par,
			headers : {
				'Content-Type' : 'application/x-www-form-urlencoded'
			}
		}).success(function(data, status, headers, config) {
			console.log(data);
			if (data["op.code"] == "Y") {
				// $scope.article = ;
				$scope.article = data["content"];
				document.getElementById("main").innerHTML=$scope.article;
				document.title = data["title"];
				$scope.title=data["title"];
				$scope.imgsrc = data["imgsrc"];
                $scope.menu = data["menu"];
				console.log($scope.article);
			} else {
				$scope.article = data["op.info"];
				$scope.title="";
			}
		}).error(function(data, status, headers, config) {
			console.log(status);
		});
	};
	$scope.load();
}

function GetQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) {
		return unescape(r[2]);
	} else {
		return null;
	}
}